package com.example.demo.area.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.demo.area.dao.Area;
import com.example.demo.area.dao.AreaUser;
import com.example.demo.area.mapper.AreaMapper;
import com.example.demo.area.mapper.AreaUserMapper;
import com.example.demo.area.service.IAreaUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;

/**
 * ******************************************************
 *
 * @author liugh9
 * @version 1.0
 * @classname AreaUserServiceImpl
 * @description
 * @date 2024/01/13 13:27
 * <p>
 * ******************************************************
 */
@Service
public class AreaUserServiceImpl extends ServiceImpl<AreaUserMapper, AreaUser> implements IAreaUserService {

    @Autowired
    private AreaUserMapper areaUserMapper;

    @Override
    public void insertAreaUserBatch(List<AreaUser> users) {
        int[] areaIds = new int[]{1, 11, 111, 112, 113, 12, 121, 122, 123, 13, 131, 132, 133};
        List<AreaUser> userList = new ArrayList<>();
        Random random = new Random();

        int length = areaIds.length;
        for (int i = 0; i < 10000; i++) {
            userList.add(new AreaUser(i+1, areaIds[random.nextInt(length)]));
        }
        saveBatch(userList);
    }
}
